#include <stdio.h>
#include <algorithm>
using namespace std;
#define N 5010
#define M 2000000100
int d[N][N], p[N], a[N], s[N];
int main()
{
	int i, j, k, l, b, n, v;
	for(scanf("%d%d", &n, &k), i=0; i<n; scanf("%d", &a[i]), i++);
	for(sort(a, a+n), i=0; i<n; s[i+1]=s[i]+a[i], i++);
	for(i=1; i<=n; i++)
		for(b=1, j=min(i, k); j>=1; j--)
		{
			if(j==1) l=i;
			else l=b;
			for(d[i][j]=M; l<=p[j]+1; l++)
			{
				v=s[i]-s[i-l/2]-s[i-l/2]+s[i-l]+a[i-1-l/2]*(l%2)+d[i-l][j-1];
				if(v<d[i][j]) { d[i][j]=v; b=l; }
			}
			p[j]=b;
		}
	printf("%.1lf\n", (double)d[n][k]);
	return 0;
}